<template>
  <div class="input-group">
    <input type="text" v-model="value">
    <button @click="handle">添加</button>
  </div>
  <!-- 左边的list是传给子组件的，右边的list是数组 -->
</template>

<script setup>
import { ref } from 'vue';
const props=defineProps({
  list:Array
})

const emits=defineEmits(['update:list'])
const value = ref('')
const handle = () => {
  const arr=props.list
  arr.push(value.value)
  emits('update:list',arr)  //调用事件
}
</script>
<style >
#app {
  width: 300px;
}

.input-group {
  width: 100%;
  display: flex;
}
</style>
